<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="skladiscenje.*"%>
<%@ page import="java.util.ArrayList"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>SKLADISCENJE systems</title>
        <LINK href="CSS/style.css" rel="stylesheet" type="text/css" />
        <LINK href="CSS/menu.css" rel="stylesheet" type="text/css" />
        <LINK REL="SHORTCUT ICON" HREF="images/favicon.ico" />
    </head>
        
    <body>
		<table id="wrapper">
			<tr>
				<td>
					<% 
					if (session.getAttribute("uporabnik") != null) {
						Uporabnik uporabnik = (Uporabnik) session.getAttribute("uporabnik");
					%>
                	<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td>
                        		<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  	<tr>
                                    	<td class="head_top"></td>
                                  	</tr>
                                  	<tr>
                                    	<td>
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                               	  	<td class="head_middle"></td>
                                                	<td class="logout_bg"><%= uporabnik.getUporabniskoIme() %></td>
                                                	<td class="logout_logo"><a href="odjava.jsp"><img src="images/logout_logo.png" alt="logout" width="34" height="28" border="0"></a></td>
                                                	<td class="logout_right"></td>
                                             	</tr>
                                            </table>
                                        </td>
                                 	</tr>
                                  	<tr>
                                  	  	<td class="head_bottom"></td>
                                  	</tr>
                                  	<tr>
                                    	<td>
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                               	  	<td class="menu_left"></td>
                                                	<td class="menu_bg"><%@ include file="meni.jsp" %></td>
                                                	<td class="menu_right"></td>
                                             	</tr>
                                            </table>
                                        </td>
                                  	</tr>
                                  	<tr>
                                    	<td class="menu_bottom"></td>
                                  	</tr>
                                </table>
							</td>
                      	</tr>
                      	<tr>
                        	<td>
                            	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  	<tr>
                                      	<td class="left"></td>
                                      	<td valign="top" bgcolor="#E7F6FF">
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                                	<td>
                                                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                          	<tr>
                                                           	  	<td class="main_left"></td>
                                                            	<td bgcolor="#FFFFFF">
                                                            		<%
                                                            		if(request.getParameter("shrani") != null){
                                                            			if(request.getParameter("sektor") != null){
                                                            				Evidenca.novSkladiscnik(request.getParameter("ime"),
                                                            										request.getParameter("priimek"),
                                                            										request.getParameter("uIme"),
                                                            										request.getParameter("geslo"),
                                                            										request.getParameter("racun"),
                                                            										request.getParameter("email"),
                                                            										request.getParameter("naslov"),
                                                            										Integer.parseInt(request.getParameter("sektor")));
                                                            				response.sendRedirect("novUporabnik.jsp?nov=skladiscnik");
                                                            			}else{
                                                            				Evidenca.novVodja(request.getParameter("ime"),
                                            												  request.getParameter("priimek"),
                                            												  request.getParameter("uIme"),
                                            												  request.getParameter("geslo"),
                                            												  request.getParameter("racun"),
                                            												  request.getParameter("email"),
                                            												  request.getParameter("naslov"));
                                                            				response.sendRedirect("novUporabnik.jsp?nov=vodja");
                                                            			}
                                                            		}
                                                            		if(request.getParameter("nov") != null){
                                                            			String nov = request.getParameter("nov");
	                                                            		if(nov.equals("skladiscnik")){
	                                                            		%>
	                                                            		<form name="novoBlago" method="get" action="">
		                                                            		<table class="urejanje" width="100%" cellspacing="3" cellpadding="2">
																				<tr>
																					<td colspan="2"><h1>Dodajanje novega skladiščnika!</h1></td>
																				</tr>
																				<tr>
																					<td class="desna">Ime: </td>
																					<td class="leva"><input type="text" name="ime" id="ime" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Priimek: </td>
																					<td class="leva"><input type="text" name="priimek" id="priimek" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Uporabniško ime: </td>
																					<td class="leva"><input type="text" name="uIme" id="uIme" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Geslo: </td>
																					<td class="leva"><input type="text" name="geslo" id="geslo" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Račun: </td>
																					<td class="leva"><input type="text" name="racun" id="racun" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">e-mail: </td>
																					<td class="leva"><input type="text" name="email" id="email" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Naslov: </td>
																					<td class="leva"><input type="text" name="naslov" id="naslov" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Sektor: </td>
																					<td class="leva"><input type="text" name="sektor" id="sektor" value="" /></td>
																				</tr>
																				<tr>
																					<td colspan="2"><input type="submit" name="shrani" value="Dodaj" /></td>
																				</tr>
																			</table>
																		</form><br />
	                                                            		<table class="izpisTabela" width="100%" cellspacing="0">
	                                                            			<tr><td class="naslov" colspan="7">- SEZNAM SKLADISCNIKOV -</td></tr>
	                                                            			<tr>
	                                                            				<th>ID</th>
	                                                            				<th>Ime</th>
	                                                            				<th>Priimek</th>
	                                                            				<th>Uporabniško ime</th>
	                                                            				<th>Email</th>
	                                                            				<th>Pravice</th>
	                                                            				<th>Sektor</th>
	                                                            			</tr>
	                                                            			<%
	                                                            			ArrayList<Skladiscnik> seznamSkladiscnikov = Evidenca.izpisVseSkladiscnike();
	                                                            			
	                                                            			if(seznamSkladiscnikov.size() < 1){
	                                                            				%>
	                                                            				<tr><td colspan="7">V skladišču trenutno ni Skladiščnika</td></tr>
	                                                            				<%
	                                                            			}else{
	                                                            				int tabela;
	                                                            				for(int i = 0; i < seznamSkladiscnikov.size(); i++){
	                                                            					if(i%2 == 0)
	                                                            						tabela = 1;
	                                                            					else
	                                                            						tabela = 2;
	                                                            					%>
	                                                            					<tr class="izpisTabela<%= tabela %>">
			                                                            				<td><%= seznamSkladiscnikov.get(i).getID() %></td>
			                                                            				<td><%= seznamSkladiscnikov.get(i).getIme() %></td>
			                                                            				<td><%= seznamSkladiscnikov.get(i).getPriimek() %></td>
			                                                            				<td><%= seznamSkladiscnikov.get(i).getUporabniskoIme() %></td>
			                                                            				<td><%= seznamSkladiscnikov.get(i).getEmail() %></td>
			                                                            				<td><%= seznamSkladiscnikov.get(i).getPravice() %></td>
			                                                            				<td><%= seznamSkladiscnikov.get(i).getSektor() %></td>
			                                                            			</tr>
	                                                            					<%
	                                                            				}
	                                                            			}
	                                                            			%>
	                                                           			</table>
	                                                           			<%
	                                                            		}else{
	                                                           			%>
	                                                           			<form name="novoBlago" method="get" action="">
		                                                            		<table class="urejanje" width="100%" cellspacing="3" cellpadding="2">
																				<tr>
																					<td colspan="2"><h1>Dodajanje novega vodje!</h1></td>
																				</tr>
																				<tr>
																					<td class="desna">Ime: </td>
																					<td class="leva"><input type="text" name="ime" id="ime" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Priimek: </td>
																					<td class="leva"><input type="text" name="priimek" id="priimek" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Uporabniško ime: </td>
																					<td class="leva"><input type="text" name="uIme" id="uIme" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Geslo: </td>
																					<td class="leva"><input type="text" name="geslo" id="geslo" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Račun: </td>
																					<td class="leva"><input type="text" name="racun" id="racun" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">e-mail: </td>
																					<td class="leva"><input type="text" name="email" id="email" value="" /></td>
																				</tr>
																				<tr>
																					<td class="desna">Naslov: </td>
																					<td class="leva"><input type="text" name="naslov" id="naslov" value="" /></td>
																				</tr>
																				<tr>
																					<td colspan="2"><input type="submit" name="shrani" value="Dodaj" /></td>
																				</tr>
																			</table>
																		</form><br />
	                                                           			<table class="izpisTabela" width="100%" cellspacing="0">
	                                                            			<tr><td class="naslov" colspan="6">- SEZNAM VODIJ -</td></tr>
	                                                            			<tr>
	                                                            				<th>ID</th>
	                                                            				<th>Ime</th>
	                                                            				<th>Priimek</th>
	                                                            				<th>Uporabniško ime</th>
	                                                            				<th>Email</th>
	                                                            				<th>Pravice</th>
	                                                            			</tr>
	                                                            			<%
	                                                            			ArrayList<VodjaSkladisca> seznamVodij = Evidenca.izpisiVseVodje();
	                                                            			if(seznamVodij.size() < 1){
	                                                            				%>
	                                                            				<tr><td colspan="6">V skladišču trenutno ni Vodje</td></tr>
	                                                            				<%
	                                                            			}else{
	                                                            				int tabela;
	                                                            				for(int i = 0; i < seznamVodij.size(); i++){
	                                                            					if(i%2 == 0)
	                                                            						tabela = 1;
	                                                            					else
	                                                            						tabela = 2;
	                                                            					%>
	                                                            					<tr class="izpisTabela<%= tabela %>">
			                                                            				<td><%= seznamVodij.get(i).getID() %></td>
			                                                            				<td><%= seznamVodij.get(i).getIme() %></td>
			                                                            				<td><%= seznamVodij.get(i).getPriimek() %></td>
			                                                            				<td><%= seznamVodij.get(i).getUporabniskoIme() %></td>
			                                                            				<td><%= seznamVodij.get(i).getEmail() %></td>
			                                                            				<td><%= seznamVodij.get(i).getPravice() %></td>
			                                                            			</tr>
	                                                            					<%
	                                                            				}
	                                                            			}
	                                                            			%>
	                                                            		</table>
                                                            			<%	
                                                            			}
                                                            		}
	                                                            	%>
																</td>
                                                            	<td class="main_right"></td>
                                                          	</tr>
                                                        </table>
                                                    </td>
                                              	</tr>
                                              	<tr>
                                                	<td class="main_bottom"></td>
                                              	</tr>
                                            </table>
                                        </td>
                                        <td width="184" valign="top" bgcolor="#E7F6FF">
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                                	<td>
                                                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                          	<tr>
                                                           	  	<td class="side_left"></td>
                                                            	<td bgcolor="#FFFFFF"><%@ include file="statistika.jsp" %></td>
                                                            	<td class="side_right"></td>
                                                          	</tr>
                                                        </table>
                                                    </td>
                                              	</tr>
                                              	<tr>
                                                	<td class="side_bottom"></td>
                                              	</tr>
                                            </table>
                                        </td>
                                        <td class="right"></td>
                                  	</tr>
                                </table>
                            </td>
                      	</tr>
                      	<tr>
                        	<td class="footer"></td>
                      	</tr>
                    </table>
                    <%}else{response.sendRedirect("index.jsp?prijava=potrebna");}%>
                </td>
			</tr>
		</table>
	</body>
</html>